From f8bb2060343800e9a51013f61966f60a5caa6bb0 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 12 Nov 2020 14:53:16 +0000 Subject: [PATCH] a11y: Icons in buttons are presentational Buttons are described by text, and the icon child can be safely ignored. --- gtk/gtkbutton.c | 5 ++++- gtk/gtkmodelbutton.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 059853106a..9e9a15a422 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -927,7 +927,10 @@ gtk_button_set_icon_name (GtkButton *button, if (priv->child_type != ICON_CHILD || priv->child == NULL) { - GtkWidget *child = gtk_image_new_from_icon_name (icon_name); + GtkWidget *child = g_object_new (GTK_TYPE_IMAGE, + "accessible-role", GTK_ACCESSIBLE_ROLE_PRESENTATION, + "icon-name", icon_name, + NULL); gtk_button_set_child (GTK_BUTTON (button), child); gtk_widget_set_valign (child, GTK_ALIGN_CENTER); gtk_widget_remove_css_class (GTK_WIDGET (button), "text-button"); diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c index c6e3d04f10..9efed319aa 100644 --- a/gtk/gtkmodelbutton.c +++ b/gtk/gtkmodelbutton.c @@ -648,7 +648,10 @@ gtk_model_button_set_icon (GtkModelButton *self, { if (!self->image && icon) { - self->image = gtk_image_new_from_gicon (icon); + self->image = g_object_new (GTK_TYPE_IMAGE, + "accessible-role", GTK_ACCESSIBLE_ROLE_PRESENTATION, + "gicon", icon, + NULL); gtk_widget_insert_before (self->image, GTK_WIDGET (self), self->label); } else if (self->image && !icon) -- 2.30.2